<script setup>
import SoundIcon from './SoundIcon.vue';

defineProps({
  size: {
    type: [Number, String],
    default: 40
  },
  type: {
    type: String,
    default: 'us'
  },
  isPlaying: {
    type: Boolean,
    default: false
  }
});
</script>

<template>
  <div class="pronunciation-button" :class="{ 'is-playing': isPlaying }">
    <div class="content">
      <span class="english-text px-1">{{ type === 'us' ? '美' : '英' }}</span>
      <SoundIcon class="sound-icon" :width="9" :height="11" color="#7B7B7B" />
      <span v-if="isPlaying" class="loading-animation"></span>
    </div>
  </div>
</template>

<style scoped>
.pronunciation-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: white;
  border-radius: 9999px;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s ease;
  vertical-align: middle;
  position: relative;
  top: 1px;
}

.pronunciation-button:hover:not(.is-playing) {
  transform: scale(1.05);
}

.pronunciation-button.is-playing {
  opacity: 0.9;
}

.content {
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 0px 3px;
  position: relative;
}

.english-text {
  font-weight: 600;
  font-size: 12px;
  color: #7B7B7B;
}

.sound-icon {
  margin-top: 1px;
}

@keyframes pulse {
  0% { opacity: 0.4; }
  50% { opacity: 1; }
  100% { opacity: 0.4; }
}

.loading-animation {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(123, 123, 123, 0.2);
  border-radius: 9999px;
  animation: pulse 1.5s infinite ease-in-out;
}
</style> 